package vip.zhenzicheng.jpa.controller;

import com.zzc.zfast.web.domain.PageResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import vip.zhenzicheng.jpa.domain.dto.StudentDTO;
import vip.zhenzicheng.jpa.domain.vo.StudentVO;
import vip.zhenzicheng.jpa.service.StudentService;

/**
 * TODO zfast 框架层应提供对 LocalDateTime 的全局转换器
 *
 * @author zhenzicheng
 * @date 2023-04-17 16:12
 */
@Api(tags = "学生管理")
@RestController
@RequestMapping("/student")
public class StudentCtrl {

    @Autowired
    private StudentService studentService;

    @ApiOperation(value = "分页查询学生列表", notes = "带模糊查询，如果不指定分页返回所有数据")
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name = "username", value = "用户名-模糊查询", dataTypeClass = String.class),
            @ApiImplicitParam(name = "nickName", value = "昵称-模糊查询", dataTypeClass = String.class),
            @ApiImplicitParam(name = "ageRange", value = "年龄范围-范围查询", dataTypeClass = String.class, example = "16,35"),
            @ApiImplicitParam(name = "sex", value = "年龄范围-范围查询", dataTypeClass = Integer.class, example = "0", allowableValues = "0,1"),
    })
    @GetMapping("/list")
    public PageResult<StudentVO> listStudent(StudentDTO dto) {
        return studentService.findAll(dto);
    }
}
